/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package myModel;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.SQLException;
import java.util.List;

/**
 *
 * @author RaheelArif
 */
public class users {
protected String UID;
protected String CreditCardNumber;
protected String Pin;
protected List reservations;
protected List purchases;

    public users() {
    }
    public boolean ValidateUser() throws ClassNotFoundException, SQLException
    {
        
        ResultSet res;
        DAO d = new DAO();
        Connection conn= d.makeConn();
        Statement stat =  conn.createStatement();
        String myQuery="Select * from users where CreditCard="+CreditCardNumber+" AND pin='"+Pin+"'";
        System.out.println(myQuery);
        res = stat.executeQuery(myQuery);
        //UID=res.getString(1);
        if(!res.next())
        {
            return false;
            
        }
        else
        {
           // res.first();
            UID=res.getString(1);
           return true;
        }
    }
    public String returnName() throws ClassNotFoundException, SQLException
    {
        
        return UID;
    }
    public void setCreditCardNumber(String CreditCardNumber) {
        this.CreditCardNumber = CreditCardNumber;
    }

    public void setPin(String Pin) {
        this.Pin = Pin;
    }

    public void setUID(String UID) {
        this.UID = UID;
    }

    public String getCreditCardNumber() {
        return CreditCardNumber;
    }

    public String getPin() {
        return Pin;
    }

    public String getUID() {
        return UID;
    }
}
